<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>管理员商品列表</title>

<link rel="stylesheet"
	href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script
	src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script
	src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<style type="text/css">
#page {
	position: absolute;
	top: 550px;
}
</style>

<script type="text/javascript">
	function tr(mes) {
		//alert(mes);
		//parent.location.href="/user/goodmes?zybgoodid="+mes;
		window
				.open('/goods/addgood', 'newwindow', 'heigth=550,width=350',
						'top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no');
	}

	function del() {

		var msg = confirm("确认删除么？");
		if (msg == true) {

			return true;
		} else {

			return false;
		}
	}
	function logout() {

		window.location.href = "/logout";
	}
</script>
</head>
<body>
	欢迎管理员${sessionScope.u.zybname}登录
	<input type="button" value="退出" onclick="logout();" />


	<div class="container">
		<div class="row clearfix">
			<div class="col-md-12 column">
				<div class="jumbotron well">
					<h3>在线购物系统</h3>
					<p>系统后台</p>

				</div>
				<ul class="breadcrumb">
					<li><a href="#">在线购物系统</a></li>
					<li><a href="#">商品管理</a></li>
					<li class="active">商品列表</li>
				</ul>
				<nav class="navbar navbar-default" role="navigation">
				<div class="container-fluid">

					<div>
						<form action="/goods/searchgood" method="post"
							class="navbar-form navbar-left" role="search">
							<div class="form-group">
								<input type="text" class="form-control" placeholder="Search"
									name="mes">
							</div>
							<input type="submit" class="btn btn-default" value="点击查询">&nbsp;
							<a href="#" class="btn btn-primary" onclick="tr();">添加</a>
						</form>

					</div>
				</div>
				</nav>
				<div>${succ }</div>
				<table class="table">
					<thead>
						<tr>
							<th>商品编号</th>
							<th>商品名称</th>
							<th>商品单价(￥)</th>
							<th>商品数量</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>

						<c:forEach items="${p.list }" var="item">
							<tr>
								<td>${item.zybgoodid }</td>
								<td>${item.zybgoodname }</td>
								<td>${item.zybprice }</td>
								<td>${item.zybquantity }</td>
								<td><a href="/goods/editgood?zybgoodid=${item.zybgoodid}">编辑</a>
									<a href="/goods/deletegood?zybgoodid=${item.zybgoodid}"
									onclick="return del();">删除</a></td>
							</tr>
						</c:forEach>


					</tbody>
				</table>

				<!--分页  -->
				<div class="row clearfix" id="page">
					<div class="col-md-12 column">
						<ul class="pagination">
							<li><a>${p.count}条记录/共${p.total }页</a></li>

							<li><c:if test="${p.total <=1}">
									<a href="#" style="disabled: true">上一页</a>
								</c:if> <c:if test="${p.total>=2 }">
									<a href="/goods/adminpagelist?current=${p.current -1}">上一页</a>
								</c:if></li>

							<c:forEach begin="1" end="${p.total }" step="1" var="index">
								<li><a href="/goods/adminpagelist?current=${index}">${index}</a></li>
							</c:forEach>
							<li><c:if test="${p.total <=1}">
									<a href="#" style="disabled: true">上一页</a>
								</c:if> <c:if test="${p.total>=2 }">
									<a
										href="/goods/adminpagelist?current=${p.current +1<=p.total?p.current +1:p.total}">下一页</a>
								</c:if></li>
						</ul>
					</div>
				</div>

			</div>
		</div>
	</div>
</body>
</html>